<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Component Test</title>
</head>
<body>
    <div id="app1">
        <my-component1></my-component1>
        <my-component1></my-component1>
        <my-component1></my-component1>
    </div>
    <br>
    <p>-----------------------------华丽的分割线-----------------------------</p>
    <div id="app2">
        <my-component2></my-component2>
        <my-component2></my-component2>
        <my-component2></my-component2>
    </div>
    <script src="https://unpkg.com/vue/dist/vue.min.js"></script>
    <script>
        var data = {
            counter: 0
        };
        Vue.component('my-component1', {
            template: '<button @click="counter++">{{ counter }}</button>',
            data: function () {
                return {
                    counter: 0
                };
            }
        });

        var app1 = new Vue({
            el: '#app1'
        });

        var app2 = new Vue({
            el: '#app2',
            components: {
                'my-component2': {
                    template: '<button @click="counter++">{{ counter }}</button>',
                    data: function () {
                        return data;
                    }
                }
            }
        })
    </script>
</body>
</html>